package top.zsyle.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.zsyle.block.GetUserBlock;
import top.zsyle.domain.User;
import top.zsyle.fallback.GetUserFallback;

@RestController
@RequestMapping("/user")
public class UserController {

    @Value("${test.value}")
    private String value;

    @GetMapping(value = "/{id}")
    @SentinelResource(value = "getUser",fallback = "getUserFallback",
            fallbackClass = GetUserFallback.class,
            blockHandler = "getUserBlock",
            blockHandlerClass = GetUserBlock.class)
    public User getUserById(@PathVariable Long id) {
//        int i = 1/0;
        return new User(id,"去去去","老子是user："+value);
    }



}
